**********************************************************************************
**********************************************************************************
*Relative Capture: Quasi-Experimental Evidence from the Chinese Judiciary*

*Comparative Political Studies*

*Yuhua Wang*
*yuhuawang@fas.harvard.edu*

*Original Do File Created on October 8, 2014*
*Replication Do File Created on March 21, 2017*

*Analysis Conducted Using STATA 14.2*
**********************************************************************************
**********************************************************************************

cd "~/CPS relative capture datafile"

use "relative capture.dta"

set more off

***********************************************************************************
*Tables and Figures in the Paper
***********************************************************************************

****************************
*I. DID Set Up
****************************

*Table 1 in Paper: exposure to each level court in each cell*

ttest basic if cell==3 | cell==4, by(cell)
ttest intermediate if cell==3 | cell==4, by(cell)
ttest intermediate if cell==5 | cell==6, by(cell)


******************************************
*II. Effect of Institutional Change on Win Rate: Intention to Treat Estimates*
******************************************

**Table 2 in Paper: intermediate->basic*

*SOE*

local controls "A_ASSETS A_AGE contractdispute road third derby"
local fe "pro2-pro31 A_ind2-A_ind6"

*\ Model (1): without controls and fixed effects
xi: reg win post2008 treatment1 post2008_treatment1 if cell>2 & A_SOESHARE>0 & cell<7, cluster(cityid)
estimates store ittmodel1

*\ Model (2): with fixed effects and without controls
xi: reg win post2008 treatment1 post2008_treatment1 `fe' if cell>2 & A_SOESHARE>0 & cell<7,cluster(cityid)
estimates store ittmodel2

*\ Model (3): with controls and fixed effects
xi: reg win post2008 treatment1 post2008_treatment1 `controls' `fe' if cell>2 & A_SOESHARE>0 & cell<7,cluster(cityid)
estimates store ittmodel3

*Non-SOE*
local controls "A_ASSETS A_AGE contractdispute road third derby"
local fe "pro2-pro31 A_ind2-A_ind6"

*\ Model (4): without controls and fixed effects
xi: reg win post2008 treatment1 post2008_treatment1 if cell>2 & A_SOESHARE==0 & cell<7, cluster(cityid)
estimates store ittmodel4

*\ Model (5): with fixed effects and without controls
xi: reg win post2008 treatment1 post2008_treatment1 `fe' if cell>2 & A_SOESHARE==0 & cell<7,cluster(cityid)
estimates store ittmodel5

*\ Model (6): with controls and fixed effects
xi: reg win post2008 treatment1 post2008_treatment1 `controls' `fe' if cell>2 & A_SOESHARE==0 & cell<7,cluster(cityid)
estimates store ittmodel6

esttab ittmodel1 ittmodel2 ittmodel3 ittmodel4 ittmodel5 ittmodel6 using ittmodel.tex, collabels(none)  cells(b(star fmt(3)) se(par)) staraux star(* 0.10 ** 0.05 *** 0.01) replace ///
stats(N r2, fmt(0 3) layout("\multicolumn{1}{c}{@}" "\multicolumn{1}{c}{@}")  labels(`"Observations"' `"\(R^{2}\)"')) title(Effect of Exposure to Basic People's Courts on Win Rate: DID Estimates\label{tab2}) 

******************************************
*III. Effect of Institutional Change on Win Rate: IV Estimates*
******************************************

*Table 3 in Paper: balance tests*

ttest A_ASSETS if cell==4, by(basic)
ttest A_AGE if cell==4, by(basic)
ttest contractdispute if cell==4, by(basic)
ttest home if cell==4, by(basic)
ttest road if cell==4, by(basic)
ttest third if cell==4, by(basic)
ttest derby if cell==4, by(basic)
ttest A_GOV if cell==4, by(basic)
ttest A_PAR if cell==4, by(basic)
ttest A_LOLEGAL if cell==4, by(basic)


*Table 4 in Paper: IV Estimates of Basic Court's Effect on Win*

local controls "A_ASSETS A_AGE contractdispute road third derby"
local fe "pro2-pro31 A_ind2-A_ind6"

*SOE*

xi: ivregress 2sls win (basic=post2008_treatment1) `controls' `fe' if A_SOESHARE>0 & cell>2 & cell<7,first cluster(cityid)
estimates store ivmodel1

*\F Statistic
xi: reg basic post2008_treatment1 `controls' `fe' if A_SOESHARE>0 & cell>2 & cell<7, cluster(cityid)
test post2008_treatment1==0

*\Hausman test
xi:ivreg win (basic=post2008_treatment1) `controls' `fe' if A_SOESHARE>0 & cell>2 & cell<7
ivendog 

*Non-SOE*
xi: ivregress 2sls win (basic=post2008_treatment1) `controls' `fe' if A_SOESHARE==0 & cell>2 & cell<7,first cluster(cityid)
estimates store ivmodel2

*\F Statistic
xi: reg basic post2008_treatment1 `controls' `fe' if A_SOESHARE==0 & cell>2 & cell<7, cluster(cityid)
test post2008_treatment1==0

*\Hausman test
xi:ivreg win (basic=post2008_treatment1) `controls' `fe' if A_SOESHARE==0 & cell>2 & cell<7
ivendog 

esttab ivmodel1 ivmodel2 using ivmodel.tex, collabels(none)  cells(b(star fmt(3)) se(par)) staraux star(* 0.10 ** 0.05 *** 0.01) replace ///
stats(N r2, fmt(0 3) layout("\multicolumn{1}{c}{@}" "\multicolumn{1}{c}{@}")  labels(`"Observations"' `"\(R^{2}\)"')) title(Effect of Exposure to Basic People's Courts on Win Rate: 2SLS Estimates\label{tab4}) 


*Table 5 in Paper: A Sub-Sample where Non-SOE vs. SOE*

local controls "A_ASSETS A_AGE contractdispute road third derby"
local fe "pro2-pro31 A_ind2-A_ind6"

*Model (1)
xi: ivregress 2sls win (basic=post2008_treatment1) if A_SOESHARE==0 & B_SOESHARE>0 & cell>2 & cell<7,cluster(cityid)
estimates store submodel1

*Model (2)
xi: ivregress 2sls win (basic=post2008_treatment1) `fe' if A_SOESHARE==0 & B_SOESHARE>0 & cell>2 & cell<7,cluster(cityid)
estimates store submodel2

*Model (3)
xi: ivregress 2sls win (basic=post2008_treatment1) `controls' `fe' if A_SOESHARE==0 & B_SOESHARE>0 & cell>2 & cell<7,cluster(cityid)
estimates store submodel3

esttab submodel1 submodel2 submodel3 using submodel.tex, collabels(none)  cells(b(star fmt(3)) se(par)) staraux star(* 0.10 ** 0.05 *** 0.01) replace ///
stats(N r2, fmt(0 3) layout("\multicolumn{1}{c}{@}" "\multicolumn{1}{c}{@}")  labels(`"Observations"' `"\(R^{2}\)"')) title(Effect of Basic Court on Win Rates of Non-SOEs versus SOEs: 2SLS Estimates\label{tab5}) 


***********************************************************************************
*Tables and Figures in the Web Appendix
***********************************************************************************

*********************
*I. Summary Statistics
*********************

*Table 1.1 in Appendix: summary statistics*

estpost sum win basic intermediate high supreme post2008 treatment1 post2008_treatment1 A_ASSETS A_AGE contractdispute home road third derby A_SOE_dummy A_SOESHARE A_GOV A_PAR A_LOLEGAL stake stake_log acceptanceyear B_SOE_dummy

esttab, cells("count mean sd min max")

*********************
*II. Identification Strategy
*********************

*Figure 2.1 in Appendix: DID graph*

bysort acceptanceyear: sum win if A_SOESHARE>0 & cell==3
bysort acceptanceyear: sum win if A_SOESHARE>0 & cell==4
bysort acceptanceyear: sum win if A_SOESHARE>0 & cell==5
bysort acceptanceyear: sum win if A_SOESHARE>0 & cell==6

bysort acceptanceyear: sum win if A_SOESHARE==0 & cell==3
bysort acceptanceyear: sum win if A_SOESHARE==0 & cell==4
bysort acceptanceyear: sum win if A_SOESHARE==0 & cell==5
bysort acceptanceyear: sum win if A_SOESHARE==0 & cell==6

**Table 2.1 in Appendix: Testing parrallel trend assumption*

*SOE*

local controls "A_ASSETS A_AGE contractdispute road third derby"
local fe "pro2-pro31 A_ind2-A_ind6"
local yearinteractions "year2000_treat1 year2001_treat1 year2002_treat1 year2003_treat1 year2004_treat1 year2005_treat1 year2006_treat1 year2007_treat1 year2008_treat1 year2009_treat1 year2010_treat1"

*\ Model (1): with fixed effects and without controls
xi: reg win `yearinteractions' `fe' if cell>2 & A_SOESHARE>0 & cell<7,cluster(cityid)
estimates store trendmodel1

*\ Model (2): with controls and fixed effects
xi: reg win `yearinteractions' `controls' `fe' if cell>2 & A_SOESHARE>0 & cell<7,cluster(cityid)
estimates store trendmodel2

*Non-SOE*
local controls "A_ASSETS A_AGE contractdispute road third derby"
local fe "pro2-pro31 A_ind2-A_ind6"
local yearinteractions "year2000_treat1 year2001_treat1 year2002_treat1 year2003_treat1 year2004_treat1 year2005_treat1 year2006_treat1 year2007_treat1 year2008_treat1 year2009_treat1 year2010_treat1"

*\ Model (3): with fixed effects and without controls
xi: reg win `yearinteractions' `fe' if cell>2 & A_SOESHARE==0 & cell<7,cluster(cityid)
estimates store trendmodel3

*\ Model (4): with controls and fixed effects
xi: reg win `yearinteractions' `controls' `fe' if cell>2 & A_SOESHARE==0 & cell<7,cluster(cityid)
estimates store trendmodel4

esttab trendmodel1 trendmodel2 trendmodel3 trendmodel4 using trendmodel.csv, cells(b(star fmt(3)) se(par)) staraux star(* 0.10 ** 0.05 *** 0.01)

*The Effect of Institutional Change in 2008 on Exposure to Different Levels of Court (Logistic Estimates)

*Table 2.2 in Appendix: intermediate->basic*

local fe "pro2-pro31 A_ind2-A_ind6"

xi: logit basic post2008 treatment1 post2008_treatment1 `fe' if cell>2 & cell<7,cluster(cityid)
estimates store expomodel1

esttab expomodel1 using expomodel1.csv, cells(b(star fmt(3)) se(par)) staraux star(* 0.10 ** 0.05 *** 0.01)

*Table 2.3 in Appendix: high->intermediate*

local fe "pro2-pro31 A_ind2-A_ind6"

xi: logit intermediate post2008 treatment2 post2008_treatment2 `fe' if cell>6, cluster(cityid)
estimates store expomodel2

esttab expomodel2 using expomodel2.csv, cells(b(star fmt(3)) se(par)) staraux star(* 0.10 ** 0.05 *** 0.01)

*********************
*III. McCrary Test
*********************

*Figure 3.1 in Appendix: McCrary Test*

DCdensity distance1, breakpoint(0) generate(Xj Yj r0 fhat se_fhat)
drop Xj Yj r0 fhat se_fhat

******************************************
*IV. The Effect of Institutional Change in 2008 on Win Rate: Intention to Treat Estimates
******************************************

**Table 4.1 in Appendix: Logit Models*

*SOE*

local controls "A_ASSETS A_AGE contractdispute road third derby"
local fe "pro2-pro31 A_ind2-A_ind6"

*\ Model (1): without controls and fixed effects
xi: logit win post2008 treatment1 post2008_treatment1 if cell>2 & A_SOESHARE>0 & cell<7, cluster(cityid)
estimates store logitmodel1

*\ Model (2): with fixed effects and without controls
xi: logit win post2008 treatment1 post2008_treatment1 `fe' if cell>2 & A_SOESHARE>0 & cell<7,cluster(cityid)
estimates store logitmodel2

*\ Model (3): with controls and fixed effects
xi: logit win post2008 treatment1 post2008_treatment1 `controls' `fe' if cell>2 & A_SOESHARE>0 & cell<7,cluster(cityid)
estimates store logitmodel3

*Non-SOE*
local controls "A_ASSETS A_AGE contractdispute road third derby"
local fe "pro2-pro31 A_ind2-A_ind6"

*\ Model (4): without controls and fixed effects
xi: logit win post2008 treatment1 post2008_treatment1 if cell>2 & A_SOESHARE==0 & cell<7, cluster(cityid)
estimates store logitmodel4

*\ Model (5): with fixed effects and without controls
xi: logit win post2008 treatment1 post2008_treatment1 `fe' if cell>2 & A_SOESHARE==0 & cell<7,cluster(cityid)
estimates store logitmodel5

*\ Model (6): with controls and fixed effects
xi: logit win post2008 treatment1 post2008_treatment1 `controls' `fe' if cell>2 & A_SOESHARE==0 & cell<7,cluster(cityid)
estimates store logitmodel6

esttab logitmodel1 logitmodel2 logitmodel3 logitmodel4 logitmodel5 logitmodel6 using logitmodel.csv, cells(b(star fmt(3)) se(par)) staraux star(* 0.10 ** 0.05 *** 0.01)


*Table 4.2 in Appendix: high->intermediate*

local controls "A_ASSETS A_AGE contractdispute road third derby"
local fe "pro2-pro31 A_ind2-A_ind6"

*\ SOEs
xi: reg win post2008 treatment2 post2008_treatment2 `controls' `fe' if cell>6 & A_SOESHARE>0,cluster(cityid)
estimates store highmodel1

*\Non-SOE*
xi: reg win post2008 treatment2 post2008_treatment2 `controls' `fe' if cell>6 & A_SOESHARE==0,cluster(cityid)
estimates store highmodel2

esttab highmodel1 highmodel2 using highmodel.csv, cells(b(star fmt(3)) se(par)) staraux star(* 0.10 ** 0.05 *** 0.01)

******************************************
*V. The Effect of Institutional Change in 2008 on Win Rate: IV Estimates
******************************************

*Table 5.1 in Appendix: First stage results

*SOE*

local controls "A_ASSETS A_AGE contractdispute road third derby"
local fe "pro2-pro31 A_ind2-A_ind6"

xi: ivregress 2sls win (basic=post2008_treatment1) `controls' `fe' if A_SOESHARE>0 & cell>2 & cell<7,first cluster(cityid)

*Non-SOE*
xi: ivregress 2sls win (basic=post2008_treatment1) `controls' `fe' if A_SOESHARE==0 & cell>2 & cell<7,first cluster(cityid)

*Table 5.2 in Appendix: high->intermediate*

local controls "A_ASSETS A_AGE contractdispute road third derby"
local fe "pro2-pro31 A_ind2-A_ind6"

*SOE*
xi: ivregress 2sls win (intermediate=post2008_treatment2) `controls' `fe' if A_SOESHARE>0 & cell>6,cluster(cityid)
estimates store high2slsmodel1

*Non-SOE*
xi: ivregress 2sls win (intermediate=post2008_treatment2) `controls' `fe' if A_SOESHARE==0 & cell>6,cluster(cityid)
estimates store high2slsmodel2

esttab high2slsmodel1 high2slsmodel2 using high2slsmodel.csv, cells(b(star fmt(3)) se(par)) staraux star(* 0.10 ** 0.05 *** 0.01)


*****************************************
*VI. Robustness Checks*
******************************************

*Table 6.2 in Appendix: Considering Political Connections*

local controls "A_ASSETS A_AGE contractdispute road third derby"
local fe "pro2-pro31 A_ind2-A_ind6"

*SOE*

*\Model (1): Government Connection
xi: ivregress 2sls win (basic=post2008_treatment1) A_GOV `controls' `fe' if A_SOESHARE>0 & cell>2 & cell<7,cluster(cityid)
estimates store govmodel1

*\Model (2): Parliament Connection
xi: ivregress 2sls win (basic=post2008_treatment1) A_PAR `controls' `fe' if A_SOESHARE>0 & cell>2 & cell<7,cluster(cityid)
estimates store parmodel1

*\Model (3): Legal Connection
xi: ivregress 2sls win (basic=post2008_treatment1) A_LOLEGAL `controls' `fe' if A_SOESHARE>0 & cell>2 & cell<7,cluster(cityid)
estimates store legalmodel1

*Non-SOE*

*\Model (4): Government Connection
xi: ivregress 2sls win (basic=post2008_treatment1) A_GOV `controls' `fe' if A_SOESHARE==0 & cell>2 & cell<7,cluster(cityid)
estimates store govmodel2

*\Model (5): Parliament Connection
xi: ivregress 2sls win (basic=post2008_treatment1) A_PAR `controls' `fe' if A_SOESHARE==0 & cell>2 & cell<7,cluster(cityid)
estimates store parmodel2

*\Model (6): Legal Connection
xi: ivregress 2sls win (basic=post2008_treatment1) A_LOLEGAL `controls' `fe' if A_SOESHARE==0 & cell>2 & cell<7,cluster(cityid)
estimates store legalmodel2

esttab govmodel1 parmodel1 legalmodel1 govmodel2 parmodel2 legalmodel2 using connectionmodel.csv, cells(b(star fmt(3)) se(par)) staraux star(* 0.10 ** 0.05 *** 0.01)


*Tables 6.3 and 6.5 in Appendix: Balance Tests for Matching and Matching Results

*Switch to R

* see "~/CPS relative capture datafile/matching/CPS Matching.R"


*Table 6.6 in Appendix: Excluding centrally controlled SOEs*

local controls "A_ASSETS A_AGE contractdispute road third derby"
local fe "pro2-pro31 A_ind2-A_ind6"

ivregress 2sls win (basic=post2008_treatment1) `controls' `fe' if A_SOESHARE>0 & cell>2 & cell<7 & discloser_id~=600115 & discloser_id~=600764 & discloser_id~=600029& discloser_id~=601111& discloser_id~=2190& discloser_id~=600737& discloser_id~=600072& discloser_id~=600896& discloser_id~=600050& discloser_id~=600005& discloser_id~=601669& discloser_id~=16& discloser_id~=601299& discloser_id~=600428& discloser_id~=600019& discloser_id~=600171& discloser_id~=601866& discloser_id~=600026& discloser_id~=601117& discloser_id~=31& discloser_id~=2051& discloser_id~=601600& discloser_id~=600482& discloser_id~=2039& discloser_id~=601766& discloser_id~=601919& discloser_id~=601918& discloser_id~=600795& discloser_id~=600489& discloser_id~=927& discloser_id~=778& discloser_id~=601808& discloser_id~=600742& discloser_id~=600583& discloser_id~=600900& discloser_id~=600027& discloser_id~=748& discloser_id~=928& discloser_id~=600705& discloser_id~=800& discloser_id~=601800& discloser_id~=600335& discloser_id~=900937& discloser_id~=600726& discloser_id~=600980& discloser_id~=900953& discloser_id~=600056& discloser_id~=600028& discloser_id~=966& discloser_id~=922& discloser_id~=601618& discloser_id~=200016& discloser_id~=601798& discloser_id~=601106& discloser_id~=601016& discloser_id~=600875& discloser_id~=601179& discloser_id~=601888& discloser_id~=600886& discloser_id~=601857& discloser_id~=600582& discloser_id~=601718& discloser_id~=601991& discloser_id~=2046& discloser_id~=601965& discloser_id~=601088& discloser_id~=798& discloser_id~=920& discloser_id~=601390& discloser_id~=601898& discloser_id~=600536& discloser_id~=600501& discloser_id~=600150& discloser_id~=600685& discloser_id~=601186& discloser_id~=601668& discloser_id~=603126& discloser_id~=600271& discloser_id~=2116& discloser_id~=600236& discloser_id~=600744& discloser_id~=600206& discloser_id~=600292& discloser_id~=601989& discloser_id~=2167& discloser_id~=777& discloser_id~=300034& discloser_id~=758& discloser_id~=2232& discloser_id~=300212& discloser_id~=600021& discloser_id~=600198& discloser_id~=851& discloser_id~=600640,cluster(cityid)
estimates store nocentralmodel

esttab nocentralmodel using nocentralmodel.csv, cells(b(star fmt(3)) se(par)) staraux star(* 0.10 ** 0.05 *** 0.01)


*Table 6.7 in Appendix: Using an RD-type strategy*

*SOE*

*Model (1): Bandwidth=[-10 Million, 10 Million]
xi: reg win post2008 stake_log post2008_stake_log if cell>2 & A_SOESHARE>0 & cell<7 & abs(distance_post2008intercutoff)<=1000, cluster(cityid)
estimates store rdmodel1

*Model (2): Bandwidth=[-5 Million, 5 Million]
xi: reg win post2008 stake_log post2008_stake_log if cell>2 & A_SOESHARE>0 & cell<7 & abs(distance_post2008intercutoff)<=500, cluster(cityid)
estimates store rdmodel2

*Model (3): Bandwidth=[-3 Million, 3 Million]
xi: reg win post2008 stake_log post2008_stake_log if cell>2 & A_SOESHARE>0 & cell<7 & abs(distance_post2008intercutoff)<=300, cluster(cityid)
estimates store rdmodel3

*Non-SOE*

*Model (4): Bandwidth=[-10 Million, 10 Million]
xi: reg win post2008 stake_log post2008_stake_log if cell>2 & A_SOESHARE==0 & cell<7 & abs(distance_post2008intercutoff)<=1000, cluster(cityid)
estimates store rdmodel4

*Model (5): Bandwidth=[-5 Million, 5 Million]
xi: reg win post2008 stake_log post2008_stake_log if cell>2 & A_SOESHARE==0 & cell<7 & abs(distance_post2008intercutoff)<=500, cluster(cityid)
estimates store rdmodel5

*Model (6): Bandwidth=[-3 Million, 3 Million]
xi: reg win post2008 stake_log post2008_stake_log if cell>2 & A_SOESHARE==0 & cell<7 & abs(distance_post2008intercutoff)<=300, cluster(cityid)
estimates store rdmodel6

esttab rdmodel1 rdmodel2 rdmodel3 rdmodel4 rdmodel5 rdmodel6 using rdmodel.csv, cells(b(star fmt(3)) se(par)) staraux star(* 0.10 ** 0.05 *** 0.01)

*Table 6.8 in Appendix: Difference-in-Difference-in-Differences*

local controls "A_ASSETS A_AGE contractdispute road third derby"
local fe "pro2-pro31 A_ind2-A_ind6"

*\ Model (1): without controls and fixed effects
xi: reg win post2008 treatment1 post2008_treatment1 A_SOESHARE soeshare_post2008_treatment1 if cell>2 & cell<7, cluster(cityid)
estimates store soesharemodel1

*\ Model (2): with fixed effects and without controls
xi: reg win post2008 treatment1 post2008_treatment1 A_SOESHARE soeshare_post2008_treatment1 `fe' if cell>2 & cell<7, cluster(cityid)
estimates store soesharemodel2

*\ Model (3): with controls and fixed effects
xi: reg win post2008 treatment1 post2008_treatment1 A_SOESHARE soeshare_post2008_treatment1 `controls' `fe' if cell>2 & cell<7, cluster(cityid)
estimates store soesharemodel3

esttab soesharemodel1 soesharemodel2 soesharemodel3 using soesharemodel.csv, cells(b(star fmt(3)) se(par)) staraux star(* 0.10 ** 0.05 *** 0.01)

clear
